package com.huawei.smartcity0102.wm;

import android.view.View;
import android.widget.FrameLayout;

import androidx.fragment.app.Fragment;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.huawei.smartcity0102.Base;
import com.huawei.smartcity0102.R;
import com.huawei.smartcity0102.all.F_All;
import com.huawei.smartcity0102.home.F_Home;
import com.huawei.smartcity0102.me.F_Me;
import com.huawei.smartcity0102.news.F_News;
import com.huawei.smartcity0102.zh.F_ZH;

/**
 * @author ZengYunyi
 * @description:
 * @date :2022/1/2 13:54
 */
public class F_W extends Base {
    private FrameLayout wfragment;
    private BottomNavigationView wbottom;

    @Override
    protected int layId() {
        return R.layout.f_w;
    }

    @Override
    protected String title() {
        return "外卖订餐";
    }

    @Override
    protected Boolean back() {
        return true;
    }

    @Override
    protected Boolean bottom() {
        return null;
    }

    @Override
    protected void init(View iv) {
        initView(iv);
        requireActivity().getSupportFragmentManager().beginTransaction().add(R.id.wfragment,new F_WHome()).commit();
        wbottom.setOnNavigationItemSelectedListener(it->{
            switch (it.getItemId()){
                case R.id.whome:
                    addw(new F_WHome());
                    title.setText("外卖订餐");
                    break;
                case R.id.wgz:
                    addw(new F_WGZ());
                    title.setText("关注");
                    break;
                case R.id.wdd:
                    addw(new F_WDD());
                    title.setText("订单");
                    break;
                case R.id.wme:
                    addw(new F_WME());
                    title.setText("我的");
                    break;
            }
            return true;
        });
    }

    public void addw(Fragment fragment){
        requireActivity().getSupportFragmentManager().beginTransaction().replace(R.id.wfragment,fragment).commit();
    }

    private void initView(View iv) {
        wfragment = (FrameLayout) iv.findViewById(R.id.wfragment);
        wbottom = (BottomNavigationView) iv.findViewById(R.id.wbottom);
    }
}
